package web.interceptor;

import org.apache.log4j.Logger;

import pojo.SysUser;
import utils.Constants;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class SysInterceptor  {
    private Logger log=Logger.getLogger(SysInterceptor.class);
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        log.debug("进入自定义拦截器==>SysInterceptor");
        HttpSession session=request.getSession();
        SysUser sysUser=(SysUser)session.getAttribute(Constants.USER_SESSION);
        if(sysUser==null){
            response.sendRedirect(request.getContextPath()+"/401.jsp");
            return false;
        }
        return true;
    }
}
